﻿using LevelEditor.Document;
using LevelEditor.Forms;

namespace LevelEditor.View
{
    public class DoUndoLayerOptions : DoUndoNothing
    {
        #region Fields

        int Index;

        Layer DoLayer;

        Layer UndoLayer;

        #endregion

        #region Constructors

        public DoUndoLayerOptions(MainForm form, int index, Layer layer):base(form)
        {
            Index = index;
            DoLayer = layer;
            UndoLayer = form.Level.Layers[Index];
        }

        #endregion

        #region Methods

        public override bool Do()
        {
            MainForm.Level.Layers[Index] = new Layer(DoLayer);
            MainForm.CurrentLayer = Index;
            MainForm.RefreshControlData();
            return base.Do();
        }

        public override void Undo()
        {
            MainForm.Level.Layers[Index] = new Layer(UndoLayer);
            MainForm.CurrentLayer = Index;
            MainForm.RefreshControlData();
        }

        public override string ToString()
        {
            return "Layer " + Index.ToString() + " options";
        }

        #endregion
    }
}
